package com.ruoyi.contactSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contactSys.domain.TbCenterBasic;
import com.ruoyi.contactSys.service.ITbCenterBasicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中心核心基础信息Controller
 *
 * @author ruoyi
 * @date 2025-11-05
 */
@RestController
@RequestMapping("/contactSys/basicInfo")
public class TbCenterBasicController extends BaseController
{
    @Autowired
    private ITbCenterBasicService tbCenterBasicService;

    /**
     * 查询中心核心基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbCenterBasic tbCenterBasic)
    {
        startPage();
        List<TbCenterBasic> list = tbCenterBasicService.selectTbCenterBasicList(tbCenterBasic);
        return getDataTable(list);
    }

    /**
     * 导出中心核心基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:export')")
    @Log(title = "中心核心基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCenterBasic tbCenterBasic)
    {
        List<TbCenterBasic> list = tbCenterBasicService.selectTbCenterBasicList(tbCenterBasic);
        ExcelUtil<TbCenterBasic> util = new ExcelUtil<TbCenterBasic>(TbCenterBasic.class);
        util.exportExcel(response, list, "中心核心基础信息数据");
    }

    /**
     * 获取中心核心基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbCenterBasicService.selectTbCenterBasicById(id));
    }

    /**
     * 新增中心核心基础信息
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:add')")
    @Log(title = "中心核心基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCenterBasic tbCenterBasic)
    {
        return toAjax(tbCenterBasicService.insertTbCenterBasic(tbCenterBasic));
    }

    /**
     * 修改中心核心基础信息
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:edit')")
    @Log(title = "中心核心基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCenterBasic tbCenterBasic)
    {
        return toAjax(tbCenterBasicService.updateTbCenterBasic(tbCenterBasic));
    }

    /**
     * 删除中心核心基础信息
     */
    @PreAuthorize("@ss.hasPermi('contactSys:basicInfo:remove')")
    @Log(title = "中心核心基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbCenterBasicService.deleteTbCenterBasicByIds(ids));
    }

    /**
     * 游客公开查询列表（分页）
     */

    @GetMapping("/public/List")
    public TableDataInfo publicList(TbCenterBasic tbCenterBasic)
    {
        // 分页
        //startPage();
        List<TbCenterBasic> list = tbCenterBasicService.selectTbCenterBasicList(tbCenterBasic);
        return getDataTable(list);
    }

    /**
     * 游客公开查询详情
     */
    @GetMapping("/public/{id}")
    public AjaxResult getPublic(@PathVariable("id") Long id)
    {
        TbCenterBasic data = tbCenterBasicService.selectTbCenterBasicById(id);
        return success(data);
    }


}
